<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
</head>
<body>
    <header class="aui-bar aui-bar-nav" id="aui-header">
        <a class="aui-btn aui-pull-left" href="../index.html">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">健康打卡</div>
    </header>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        账号
                    </div>
                    <div class="aui-list-item-input">
                        <input id="username" type="text" placeholder="例如：zhangsan18">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        密码
                    </div>
                    <div class="aui-list-item-input">
                        <input id="password" type="password" placeholder="Password">
                    </div>
                </div>
			</li>
			<li class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
                    <div class="aui-btn aui-btn-info aui-margin-r-5">
                        <a onclick="logout()">提交</a>
                    </div>
                    <div class="aui-btn aui-btn-danger aui-margin-l-5">
                        <a href="../index.html">取消</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
	<footer class="aui-bar aui-bar-tab aui-border-t" id="footer">
        <div class="aui-bar-tab-item aui-active" tapmode>
            <i class="aui-iconfont aui-icon-home"></i>
            <div class="aui-bar-tab-label">
                <a href="../index.html">首页</a>
            </div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <i class="aui-iconfont aui-icon-star"></i>
            <div class="aui-bar-tab-label">
                <a href="../html/money.html">打赏</a>
            </div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <i class="aui-iconfont aui-icon-my"></i>
            <div class="aui-bar-tab-label">
                <a href="../html/login.html">我的</a>
            </div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <i class="aui-iconfont aui-icon-close"></i>
            <div class="aui-bar-tab-label">
                <a href="../html/logout.html">注销</a>
            </div>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../../script/aui-toast.js" ></script>
<script src="../script/jquery.min.js"></script>
<script type="text/javascript">
    function logout(){
		var toast = new auiToast({
		})
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
		var formData = new FormData();
		var regn = new RegExp("^[0-9]*$");
		var rega = new RegExp("^[a-zA-Z]+$");
		if(username =="" || username == null || username == undefined)
		{
			toast.fail({title:"账号为空",duration:2000});
			return;
		}
		if(regn.test(username))
		{
			toast.fail({title:"账号为纯数字",duration:2000});
			return;
		}
		if(rega.test(username))
		{
			toast.fail({title:"账号为纯英文",duration:2000});
			return;
		}
		if(password =="" || password == null || password == undefined)
		{
			toast.fail({title:"密码为空",duration:2000});
			return;
		}
		if(password.length<6)
		{
			toast.fail({title:"密码过短",duration:2000});
			return;
		}
        formData.append("a",username);
		formData.append("b",password);
        $.ajax({
            url: "http://127.0.0.1/logout",
            type: 'POST',
            async: false,
            data: formData,
            processData: false,// 告诉jQuery不要去处理发送的数据
            contentType: false,// 告诉jQuery不要去设置Content-Type请求头
            success: function (data) {
                if(data['result'] == 1)
                    toast.success({title:"提交成功！",duration:2000});
                else
                    toast.success({title:"提交失败！",duration:2000});
            },
            error:function(){
                toast.success({title:"提交失败！",duration:2000});
            }
        });
    };
</script>
</html>